<template>
  <div id="gameCreate">
    <div class="backBtn fz_bold fz_28"> <span @click.stop="navitorBack"><i class="el-icon-arrow-left c_00"></i> 返回</span></div>
    <div class="createGame fz_64 c_00 fz_bold t_c">创建多人游戏</div>
    <div class="difficultyLevel fz_32 c_00 fz_bold">请选择游戏难度</div>
    <div class="levels">
      <div class="bc_16 t_c c_ff fz_36 fz_bold " @click.stop="createGame('简单')">简&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;单</div>
      <div class="bc_16 t_c c_ff fz_36 fz_bold " @click.stop="createGame('普通')">普&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;通</div>
      <div class="bc_16 t_c c_ff fz_36 fz_bold " @click.stop="createGame('困难')">困&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;难</div>
    </div>
    <div class="gameNotes fz_32 c_00 fz_bold">游戏说明</div>
    <div class="information fz_26 c_33">
      <p >任意一人进入游戏后，游戏开始计时。其他人输入相同的游戏码可以加入到游戏中。如中途离开游戏后，可以再次输入游戏码返回游戏。</p>
      <p class="pl_10">难度说明：简单 120分钟  找寻10个展品；</p>
      <p class="pl_15">普通  120分钟  找寻20个展品；</p>
      <p class="pl_15">困难  90 分钟   找寻30个展品。</p>
      <p class="pl_10">游戏中找寻的展品随机分布在2~4楼。</p>
    </div>
    <div class="dialog" :class="{d_none:orDialog}">
      <div class="dialog_item">
        <div class="title t_c fz_36 c_19 ">确认创建游戏</div>
        <div class="content t_c fz_28 c_33">是否创建多人游戏（{{diffculLevel}}）?</div>
        <div class="btns">
          <span class="cancel t_c c_33 fz_28" @click.stop="cancel">取消</span>
          <span class="sure bc_16 t_c c_ff fz_28" @click.stop="create">确定</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  require("./flexible.js");
  import ApiClient from '@/utils/ApiClient'
  export default {
    name: "gameCreate",
    data(){
      return{
        orDialog:true,
        diffculLevel:""
      }
    },
    methods:{
      navitorBack(){
        this.$router.back()
      },
      createGame(val){
        this.orDialog=false;
        this.diffculLevel=val;
      },
      cancel(){
        this.orDialog=true;
      },
      create(){
        let gameLevel="";
        let that=this;
        switch (this.diffculLevel) {
          case "简单":
            // console.log("简单游戏已创建")
            gameLevel=0;
            break;
          case "普通":
            gameLevel=1;
            // console.log("普通游戏已创建")
            break;
          case "困难":
            gameLevel=2;
            // console.log("困难游戏已创建")
            break;
        }
        // let obj={
        //   activityFlag:gameLevel
        // }
        ApiClient.post(`/app/activity/${gameLevel}/create.do`).then((res) => {
          console.log(res)
          that.$router.push({
            name:'gameCode',
            query:{
              accessCode:res.accessCode,
              id:res.id
            }
          })
        })

        this.orDialog=true;
      }
    }
  }
</script>

<style scoped lang="scss">
  @import "./base.css";
  #gameCreate{
    background-color: #fff;
    .d_none{
      display: none;
    }
    div{
      box-sizing: border-box;
    }
    .pl_10{
      padding-left: 0.2rem  ;
    }
    .pl_15{
      padding-left: 1.5rem;
    }
    .backBtn{
      width: 100%;
      height: 0.7rem;
      display: flex;
      align-items: center;
      padding-left: 0.1rem;

      span{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding-right: 0.5rem;
      }
    }
    .createGame{
      width: 100%;
      height: 1.2rem;
    }
    .difficultyLevel,.gameNotes{
      padding-left: 0.45rem;
      width:100% ;
      height: 0.6rem;
      display: flex;
      align-items: flex-end;

    }
    .gameNotes{
      margin-top: 1rem;
    }
    .levels{
      width: 100%;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      div{
        margin-top: 0.6rem;
        width: 5rem;
        height: 1.2rem;
        border-radius: 0.1rem;

      }
    }
    .information{
      width: 100%;
      padding:0.15rem 0.55rem 0.3rem;
      p{
        margin:0;
        line-height: 1.5;
      }
    }
    .dialog{
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0,0,0,.7);
      .dialog_item{
        width: 5.5rem;
        position: absolute;
        padding: 0.6rem 0.3rem;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-75%);
        border-radius: 0.2rem;
        /*box-shadow: 0 0 0.05rem 0.01rem #ddd;*/
        background-color: #fff;
        z-index: 1000;
        .title{
          height: 0.3rem;
        }
        .content{
          padding: 0.4rem 0.1rem;
        }
        .btns{
          display: flex;
          justify-content: flex-end;
          span{
            width: 1.2rem;
            height: 0.6rem;
            border-radius:0.1rem;
            border:0.01rem solid #ccc;
            margin-right: 0.2rem;
          }
          .sure{
            border-color: #169BD5;
          }
        }
      }
    }

  }
</style>
